﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rocket : MonoBehaviour
{
    public GameObject explosion;
    public static PlayerControl playerCtrl;


    // Start is called before the first frame update
    void Start()
    {
        Destroy(gameObject, 2);
    }

    void onExplode()
    {
        Quaternion q = Quaternion.Euler(0, 0, Random.Range(0, 360));
        Instantiate(explosion, transform.position, q);
    }

    void OnTriggerEnter2D(Collider2D col)
    {
        //Debug.Log(col.tag);
        //if (col.tag != "Player")
        //{
        //    if(col.tag == "Enemy")
        //    {
        //        col.gameObject.GetComponent<Enemy>().hurt();   
        //    }
        //    else if(col.tag == "Bomb")
        //    {
        //        col.GetComponent<Bomb>().onExplode();
        //    }
        //    else if(col.tag == "Other")
        //    {
        //        Debug.Log("xxx");
        //        col.GetComponent<HealthPickup>().Drop();
        //    }

        //}
        if(col.tag == "Player")
        {
            playerCtrl.Damage();
        }
        Destroy(gameObject);
        onExplode();
    }
}
